package com.shi.algorithm.recursion.single;

/**
 * 递归反向打印字符串
 */
public class E02ReversePrintString {
    public static void main(String[] args) {
        reversePrintString(0, "a");
        System.out.println("-----------------");
        reversePrintString(0, "abcd");
        System.out.println("-----------------");
        reversePrintString(0, "");
    }

    public static void reversePrintString(int n, String s){
        if (n == s.length()) {
            return ;
        }
        reversePrintString(n + 1, s);
        System.out.println(s.charAt(n));
    }
}
